Google News
logo
JavaScript - Interview Questions
What is console.log() and why it is used?
It is not a jQuery feature but a feature for debugging purposes used by developers. It is used to writes a message to the console.
 
console.log() accepts a parameter which can be an object, an array or any message.
 
Syntax : console.log(name); // here name is object, an array or variable.
 
Example :
                                                    
$('#form').submit(function() {

     console.log(‘Your form is submitted successfully!’);

     // do something

}); 
Advertisement